<?php
session_start();

if (isset($_POST['nickname'])) {
    $funcionando = apc_fetch('juego_funcionando');

    if (!$funcionando) {
        $_SESSION['rol'] = 'dibujante';
        apc_store('juego_funcionando', true);
    } else {
        $_SESSION['rol'] = 'adivinador';
    }
    $_SESSION['nickname'] = $_POST['nickname'];
    header("Location: dibujar.php");
}

?><!DOCTYPE html>
<html lang="en"><head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>Hackathon Login</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- Le styles -->
        <link href="css/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-top: 40px;
                padding-bottom: 40px;
                background-color: #f5f5f5;
            }

            .form-signin {
                max-width: 300px;
                padding: 19px 29px 29px;
                margin: 0 auto 20px;
                background-color: #fff;
                border: 1px solid #e5e5e5;
                -webkit-border-radius: 5px;
                -moz-border-radius: 5px;
                border-radius: 5px;
                -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
            }
            .form-signin .form-signin-heading,
            .form-signin .checkbox {
                margin-bottom: 10px;
            }
            .form-signin input[type="text"],
            .form-signin input[type="password"] {
                font-size: 16px;
                height: auto;
                margin-bottom: 15px;
                padding: 7px 9px;
            }

        </style>
        <link href="css/bootstrap-responsive.css" rel="stylesheet">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

    </head>

    <body>

        <div class="container">

            <form class="form-signin" method="POST">
                <h2 class="form-signin-heading">Elija un apodo</h2>
                <input class="input-block-level" placeholder="Nickname" type="text" name="nickname">
                <button class="btn btn-large btn-primary" type="submit">Conectarse</button>
            </form>

        </div> <!-- /container -->


    </body></html>